<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('编辑班级')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-profession-update">
        <input id="treeId" name="parentId" type="hidden" th:value="${profession.parentId}"/>
        <input name="profId" type="hidden" th:value="${profession.profId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">上级：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="text" onclick="selectProfessionTree()" id="treeName"
                           readonly="true"
                           th:value="${profession.parentName}">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="profName" id="profName" th:value="${profession.profName}"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orderNum" th:value="${profession.orderNum}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">负责人：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="leader" th:value="${profession.leader}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系电话：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="phoneNum" th:value="${profession.phoneNum}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">邮箱：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="email" th:value="${profession.email}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                    <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:field="*{profession.status}"
                           th:checked="${dict.isDefault == 'Y' ? true : false}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "maintenance/profession";

    $("#form-dept-add").validate({
        onkeyup: false,
        rules: {
            orderNum: {
                digits: true
            },
            email: {
                email: true,
            },
            phoneNum: {
                isPhone: true,
            },
        },
        messages: {},
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.savePut(prefix + "/edit", $('#form-profession-update').serialize());
        }
    }

    /*班级管理-新增-选择父部门树*/
    function selectProfessionTree() {
        var profId = $("#treeId").val();
        if (profId > 0) {
            var options = {
                title: '班级选择',
                width: "380",
                url: prefix + "/selectProfessionTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        } else {
            $.modal.alertError("父级不能选择");
        }
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        layer.close(index);
    }
</script>
</body>
</html>
